package com.qidian.buy.controller;

import com.qidian.buy.entity.Customer;
import com.qidian.buy.service.IOrdersService;
import com.qidian.buy.util.pojo.QDResult;
import com.qidian.buy.util.vo.OrderSaveVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author 郭浩
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
public class OrdersController {
    @Autowired
    private IOrdersService ordersService;

    @RequestMapping("/add")
    public QDResult add(OrderSaveVo vo, HttpServletRequest request){
        System.out.println(vo);
        Customer c = (Customer) request.getAttribute("loginCustomer");
        ordersService.addOrder(c,vo);
        return QDResult.ok();
    };
}
